package jp.co.nes.awssupport.business.logic.description;

/**
 * DatabaseMigrationService用の説明作成です。
 */
public class AWSDatabaseMigrationServiceDescriptionImpl extends BaseDescriptionImpl {

    /**
     * デフォルトコンストラクタです。
     */
    public AWSDatabaseMigrationServiceDescriptionImpl() {
    }

    /*
     * (非 Javadoc)
     * @see jp.co.nes.awssupport.business.logic.description.BaseDescriptionImpl#buildDescriptionFromUsageType(java.lang.String, java.lang.String, jp.co.nes.awssupport.business.logic.description.BaseDescriptionImpl.UsageTypeTokenizer)
     */
    @Override
    protected String buildDescriptionFromUsageType(String regionCode, String productName,
            UsageTypeTokenizer usageTypeTokenizer) {
        String kindValue = descriptionInfoHelper.get(productName, usageTypeTokenizer.getKind());
        String instanceType = usageTypeTokenizer.getInstanceType();
        String operation = usageTypeTokenizer.getOperation();
        String operationValue = descriptionInfoHelper.get(productName, operation);
        if (operationValue == null && operation != null) {
            return null;
        }

        StringBuilder builder = new StringBuilder();
        if (kindValue != null && instanceType != null) {
            builder.append(getDescriptionPrefix(regionCode));
            builder.append(kindValue);
            if (operationValue != null) {
                builder.append(FWC).append(operationValue);
            }

            final String TARGET = "dms.";
            if (instanceType.indexOf(TARGET) >= 0) {
                instanceType = instanceType.replace(TARGET, "");
            }
            builder.append(FWC).append(instanceType);
        }
        return builder.toString();
    }
}
